package com.webflux.tm.webflux.module.test.init;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * @author Surging
 * @version 1.0
 * @ClassName UserController
 * @date 2023-05-08 17:42
 * @desc
 */
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/users/{id}")
    public Mono<User> getUser(@PathVariable int id) {
        return userService.selectById(id);
    }

    @GetMapping("/users")
    public Flux<User> getAllUsers() {
        return userService.selectAllUsers();
    }

}
